package com.collect.tanzania.zhiAdater.zhiPhoneReview;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.collect.tanzania.R;
import com.collect.tanzania.zhiHelper.ZHIPhoneCallHelper;
import com.collect.tanzania.zhiUtils.StringUtil;

public class ZHIPhoneSelfAdjuster extends BaseQuickAdapter<String, BaseViewHolder> {

    private ZHIPhoneAdjusterClickListener mZHIPhoneAdjusterClickListener;

    public ZHIPhoneSelfAdjuster() {
        super(R.layout.item_phone_self_list, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        try {
            item = StringUtil.safeString(item);
            String formatItem = StringUtil.phoneNumberEncryptFormatter(item);
            helper.setText(R.id.tv_psa_phone, formatItem);

            ImageView iv_psa_call_phone = helper.getView(R.id.iv_psa_call_phone);
            final String finalItem = item;
            iv_psa_call_phone.setOnClickListener(v -> {

                //统一控制电话操作
                ZHIPhoneCallHelper.getInstance().startPhoneCall(mContext, finalItem, "");
//                ZHISysShareHelper.callPhone(MyApplication.getAppContext(), finalItem);
            });

            ImageView iv_psa_sms = helper.getView(R.id.iv_psa_sms);
            iv_psa_sms.setOnClickListener(v -> {
                if (mZHIPhoneAdjusterClickListener != null) {
                    mZHIPhoneAdjusterClickListener.onPhoneItemClick(ZHIPhoneAdjusterClickListener.PHONE_CLICK_TYPE_SMS, finalItem);
                }
            });

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setPhoneAdjusterClickListener(ZHIPhoneAdjusterClickListener clickListener) {
        this.mZHIPhoneAdjusterClickListener = clickListener;
    }
}
